package cn.roadtrip.uredismodule.util;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisConnectionUtils;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.concurrent.TimeUnit;

@Component
public class RedisUtil {

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    /**
     * 设置超时
     * @param key
     * @param seconds
     * @return
     */
    public boolean setExpire(String key, long seconds) {
        try {
            return stringRedisTemplate.expire(key, seconds, TimeUnit.SECONDS);
        } catch (Exception _e) {
            _e.printStackTrace();
            try {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
                Thread.sleep(1);
                return stringRedisTemplate.expire(key, seconds, TimeUnit.SECONDS);
            } catch (Exception _ee) {
                _ee.printStackTrace();
                return false;
            } finally {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
            }
        } finally {
            RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
        }
    }

    /**
     * 是否存在健
     *
     * @param key
     * @return
     */
    public boolean existKey(String key) {
        try {
            return stringRedisTemplate.hasKey(key);
        } catch (Exception _e) {
            _e.printStackTrace();
            try {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
                Thread.sleep(1);
                return stringRedisTemplate.hasKey(key);
            } catch (Exception _ee) {
                _ee.printStackTrace();
                return false;
            } finally {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
            }
        } finally {
            RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
        }
    }

    /**
     * 超时
     *
     * @param key
     * @param timeout
     */
    public void expire(String key, long timeout) {

        try {
            stringRedisTemplate.expire(key, timeout, TimeUnit.SECONDS);
        } catch (Exception _e) {
            _e.printStackTrace();
            try {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
                Thread.sleep(1);
                stringRedisTemplate.expire(key, timeout, TimeUnit.SECONDS);
                return;
            } catch (Exception _ee) {
                _ee.printStackTrace();
                return;
            } finally {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
            }
        } finally {
            RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
        }

    }

    /**
     * 删除健
     *
     * @param key
     */
    public Boolean deleteKey(String key) {

        try {
            return stringRedisTemplate.delete(key);
        } catch (Exception _e) {
            _e.printStackTrace();
            try {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
                Thread.sleep(1);
                return stringRedisTemplate.delete(key);
            } catch (Exception _ee) {
                _ee.printStackTrace();
                return false;
            } finally {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
            }
        } finally {
            RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
        }

    }

    /**
     * 如果不存在再保存
     *
     * @param key
     * @param value
     * @param time
     */
    public Boolean setIfAbsent(String key, String value, Long time) {
        try {
            if (time != null) {
                return stringRedisTemplate.opsForValue().setIfAbsent(key, value, time, TimeUnit.SECONDS);
            } else {
                return stringRedisTemplate.opsForValue().setIfAbsent(key, value);
            }
        } catch (Exception _e) {
            _e.printStackTrace();
            try {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
                Thread.sleep(1);
                if (time != null) {
                    return stringRedisTemplate.opsForValue().setIfAbsent(key, value, time, TimeUnit.SECONDS);
                } else {
                    return stringRedisTemplate.opsForValue().setIfAbsent(key, value);
                }
            } catch (Exception _ee) {
                _ee.printStackTrace();
                return false;
            } finally {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
            }
        } finally {
            RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
        }
    }

    /**
     * 设置结果
     *
     * @param key
     * @param value
     * @param seconds
     */
    public void set(String key, String value, Long seconds) {
        try {
            if (seconds != null) {
                stringRedisTemplate.opsForValue().set(key, value, seconds, TimeUnit.SECONDS);
            } else {
                stringRedisTemplate.opsForValue().set(key, value);
            }
        } catch (Exception _e) {
            _e.printStackTrace();
            try {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
                Thread.sleep(1);
                if (seconds != null) {
                    stringRedisTemplate.opsForValue().set(key, value, seconds, TimeUnit.SECONDS);
                } else {
                    stringRedisTemplate.opsForValue().set(key, value);
                }
                return;
            } catch (Exception _ee) {
                _ee.printStackTrace();
                return;
            } finally {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
            }
        } finally {
            RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
        }
    }

    /**
     * 获取值
     *
     * @param key
     * @return
     */
    public String get(String key) {
        if (key == null)
            return null;
        try {
            return stringRedisTemplate.opsForValue().get(key);
        } catch (Exception _e) {
            _e.printStackTrace();
            try {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
                Thread.sleep(1);
                return stringRedisTemplate.opsForValue().get(key);
            } catch (Exception _ee) {
                _ee.printStackTrace();
                return null;
            } finally {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
            }
        } finally {
            RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
        }
    }

    public void lLeftPush(String key, String... values) {
        if (key == null)
            return;
        if (values == null || values.length == 0)
            return;

        try {

            if (values.length == 1) {
                stringRedisTemplate.opsForList().leftPush(key, values[0]);
                return;
            }
        } catch (Exception _e) {
            _e.printStackTrace();
            try {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
                Thread.sleep(1);
                if (values.length == 1) {
                    stringRedisTemplate.opsForList().leftPush(key, values[0]);
                    return;
                }
                return;
            } catch (Exception _ee) {
                _ee.printStackTrace();
                return;
            } finally {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
            }
        } finally {
            RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
        }

        try {
            stringRedisTemplate.opsForList().leftPushAll(key, values);
        } catch (Exception _e) {
            _e.printStackTrace();
            try {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
                Thread.sleep(1);
                stringRedisTemplate.opsForList().leftPushAll(key, values);
                return;
            } catch (Exception _ee) {
                _ee.printStackTrace();
                return;
            } finally {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
            }
        } finally {
            RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
        }
    }

    public void lLeftPushIfAbsent(String key, String value) {
        if (key == null || value == null)
            return;

        try {

            stringRedisTemplate.opsForList().leftPushIfPresent(key, value);
        } catch (Exception _e) {
            _e.printStackTrace();
            try {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
                Thread.sleep(1);
                stringRedisTemplate.opsForList().leftPushIfPresent(key, value);
                return;
            } catch (Exception _ee) {
                _ee.printStackTrace();
                return;
            } finally {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
            }
        } finally {
            RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
        }
    }

    public void lRightPushIfAbsent(String key, String value) {
        if (key == null || value == null)
            return;

        try {
            stringRedisTemplate.opsForList().rightPushIfPresent(key, value);
        } catch (Exception _e) {
            _e.printStackTrace();
            try {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
                Thread.sleep(1);
                stringRedisTemplate.opsForList().rightPushIfPresent(key, value);
                return;
            } catch (Exception _ee) {
                _ee.printStackTrace();
                return;
            } finally {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
            }
        } finally {
            RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
        }
    }

    public void lRightPush(String key, String... values) {
        if (key == null)
            return;
        if (values == null || values.length == 0)
            return;
        if (values.length == 1) {
            try {
                stringRedisTemplate.opsForList().rightPush(key, values[0]);
            } catch (Exception _e) {
                _e.printStackTrace();
                try {
                    RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
                    Thread.sleep(1);
                    stringRedisTemplate.opsForList().rightPush(key, values[0]);
                    return;
                } catch (Exception _ee) {
                    _ee.printStackTrace();
                    return;
                } finally {
                    RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
                }
            } finally {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
            }
            return;
        }

        try {
            stringRedisTemplate.opsForList().rightPushAll(key, values);
        } catch (Exception _e) {
            _e.printStackTrace();
            try {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
                Thread.sleep(1);
                stringRedisTemplate.opsForList().rightPushAll(key, values);
                return;
            } catch (Exception _ee) {
                _ee.printStackTrace();
                return;
            } finally {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
            }
        } finally {
            RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
        }
    }

    /**
     * 列表-取出全部值
     *
     * @param key
     * @return
     */
    public java.util.List<String> lGetAll(String key) {
        if (key == null)
            return new ArrayList<>();

        try {
            return stringRedisTemplate.opsForList().range(key, 0, -1);
        } catch (Exception _e) {
            _e.printStackTrace();
            try {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
                Thread.sleep(1);
                return stringRedisTemplate.opsForList().range(key, 0, -1);
            } catch (Exception _ee) {
                _ee.printStackTrace();
                return null;
            } finally {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
            }
        } finally {
            RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
        }
    }

    /**
     * 列表-从左取出值
     *
     * @param key
     * @return
     */
    public String lLeftPop(String key) {
        if (key == null)
            return null;

        try {
            return stringRedisTemplate.opsForList().leftPop(key);
        } catch (Exception _e) {
            _e.printStackTrace();
            try {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
                Thread.sleep(1);
                return stringRedisTemplate.opsForList().leftPop(key);
            } catch (Exception _ee) {
                _ee.printStackTrace();
                return null;
            } finally {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
            }
        } finally {
            RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
        }
    }

    /**
     * 列表-从左取出值
     *
     * @param key
     * @param count
     * @return
     */
    public java.util.List<String> lLeftPop(String key, long count) {
        if (key == null)
            return new ArrayList<>();

        try {
            return stringRedisTemplate.opsForList().leftPop(key, count);
        } catch (Exception _e) {
            _e.printStackTrace();
            try {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
                Thread.sleep(1);
                return stringRedisTemplate.opsForList().leftPop(key, count);
            } catch (Exception _ee) {
                _ee.printStackTrace();
                return null;
            } finally {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
            }
        } finally {
            RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
        }
    }

    /**
     * 列表-从右取出值
     *
     * @param key
     * @return
     */
    public String lRightPop(String key) {
        if (key == null)
            return null;

        try {
            return stringRedisTemplate.opsForList().rightPop(key);
        } catch (Exception _e) {
            _e.printStackTrace();
            try {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
                Thread.sleep(1);
                return stringRedisTemplate.opsForList().rightPop(key);
            } catch (Exception _ee) {
                _ee.printStackTrace();
                return null;
            } finally {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
            }
        } finally {
            RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
        }
    }

    /**
     * 列表-从右取出值
     *
     * @param key
     * @param count
     * @return
     */
    public java.util.List<String> lRightPop(String key, long count) {
        if (key == null)
            return new ArrayList<>();

        try {
            return stringRedisTemplate.opsForList().rightPop(key, count);
        } catch (Exception _e) {
            _e.printStackTrace();
            try {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
                Thread.sleep(1);
                return stringRedisTemplate.opsForList().rightPop(key, count);
            } catch (Exception _ee) {
                _ee.printStackTrace();
                return null;
            } finally {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
            }
        } finally {
            RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
        }
    }

    /**
     * 列表-替换值
     *
     * @param key
     * @param oldobj
     * @param newobj
     */
    public void lReplaceValue(String key, String oldobj, String newobj) {
        if (key == null || oldobj == null || newobj == null)
            return;

        try {
            long index = stringRedisTemplate.opsForList().indexOf(key, oldobj);
            stringRedisTemplate.opsForList().set(key, index, newobj);
        } catch (Exception _e) {
            _e.printStackTrace();
            try {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
                Thread.sleep(1);
                long index = stringRedisTemplate.opsForList().indexOf(key, oldobj);
                stringRedisTemplate.opsForList().set(key, index, newobj);
                return;
            } catch (Exception _ee) {
                _ee.printStackTrace();
                return;
            } finally {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
            }
        } finally {
            RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
        }
    }

    /**
     * 列表当前长度
     *
     * @param key
     * @return
     */
    public long lSize(String key) {

        try {
            return stringRedisTemplate.opsForList().size(key);
        } catch (Exception _e) {
            _e.printStackTrace();
            try {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
                Thread.sleep(1);
                return stringRedisTemplate.opsForList().size(key);
            } catch (Exception _ee) {
                _ee.printStackTrace();
                return 0;
            } finally {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
            }
        } finally {
            RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
        }
    }

    /**
     * 截断列表长度
     *
     * @param key
     * @param startIndex
     * @param endIndex
     */
    public void lTrim(String key, long startIndex, long endIndex) {

        try {
            stringRedisTemplate.opsForList().trim(key, startIndex, endIndex);
        } catch (Exception _e) {
            _e.printStackTrace();
            try {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
                Thread.sleep(1);
                stringRedisTemplate.opsForList().trim(key, startIndex, endIndex);
                return;
            } catch (Exception _ee) {
                _ee.printStackTrace();
                return;
            } finally {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
            }
        } finally {
            RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
        }
    }

    /**
     * 列表-是否存在值
     *
     * @param key
     * @param value
     * @return
     */
    public boolean lExistValue(String key, String value) {
        if (value == null)
            return false;
        try {
            Long index = stringRedisTemplate.opsForList().indexOf(key, value);
            return index != null;
        } catch (Exception _e) {
            _e.printStackTrace();
            try {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
                Thread.sleep(1);
                Long index = stringRedisTemplate.opsForList().indexOf(key, value);
                return index != null;
            } catch (Exception _ee) {
                _ee.printStackTrace();
                return false;
            } finally {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
            }
        } finally {
            RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
        }
    }

    public void hDeleteKeys(String key, String... hashKeys) {
        if (key == null)
            return;
        if (hashKeys == null || hashKeys.length == 0)
            return;
        try {
            stringRedisTemplate.opsForHash().delete(key, hashKeys);
        } catch (Exception _e) {
            _e.printStackTrace();
            try {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
                Thread.sleep(1);
                stringRedisTemplate.opsForHash().delete(key, hashKeys);
                return;
            } catch (Exception _ee) {
                _ee.printStackTrace();
                return;
            } finally {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
            }
        } finally {
            RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
        }
    }

    public <K, V> java.util.Map<K, V> hEntities(String key) {
        try {
            return (java.util.Map<K, V>) stringRedisTemplate.opsForHash().entries(key);
        } catch (Exception _e) {
            _e.printStackTrace();
            try {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
                Thread.sleep(1);
                return (java.util.Map<K, V>) stringRedisTemplate.opsForHash().entries(key);
            } catch (Exception _ee) {
                _ee.printStackTrace();
                return null;
            } finally {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
            }
        } finally {
            RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
        }
    }

    public void hPut(String key, String hashKey, Object hashValue) {
        if (key == null || hashKey == null || hashValue == null)
            return;
        try {
            stringRedisTemplate.opsForHash().put(key, hashKey, hashValue);
        } catch (Exception _e) {
            _e.printStackTrace();
            try {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
                Thread.sleep(1);
                stringRedisTemplate.opsForHash().put(key, hashKey, hashValue);
                return;
            } catch (Exception _ee) {
                _ee.printStackTrace();
                return;
            } finally {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
            }
        } finally {
            RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
        }
    }

    public void hPutAll(String key, java.util.Map map) {
        if (key == null)
            return;
        if (map == null || map.isEmpty())
            return;

        try {
            stringRedisTemplate.opsForHash().putAll(key, map);
        } catch (Exception _e) {
            _e.printStackTrace();
            try {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
                Thread.sleep(1);
                stringRedisTemplate.opsForHash().putAll(key, map);
                return;
            } catch (Exception _ee) {
                _ee.printStackTrace();
                return;
            } finally {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
            }
        } finally {
            RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
        }
    }

    public long hSize(String key) {
        if (key == null || key.equals(""))
            return 0;

        try {
            return stringRedisTemplate.opsForHash().size(key);
        } catch (Exception _e) {
            _e.printStackTrace();
            try {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
                Thread.sleep(1);
                return stringRedisTemplate.opsForHash().size(key);
            } catch (Exception _ee) {
                _ee.printStackTrace();
                return 0;
            } finally {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
            }
        } finally {
            RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
        }
    }

    public Long hIncrement(String key, String hashKey, Long num) {
        try {
            return stringRedisTemplate.opsForHash().increment(key, hashKey, num);
        } catch (Exception _e) {
            _e.printStackTrace();
            try {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
                Thread.sleep(1);
                return stringRedisTemplate.opsForHash().increment(key, hashKey, num);
            } catch (Exception _ee) {
                _ee.printStackTrace();
                return 0l;
            } finally {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
            }
        } finally {
            RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
        }
    }

    public boolean hExistKey(String key, String hashKey) {
        if (key == null || hashKey == null)
            return false;

        try {
            return stringRedisTemplate.opsForHash().hasKey(key, hashKey);
        } catch (Exception _e) {
            _e.printStackTrace();
            try {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
                Thread.sleep(1);
                return stringRedisTemplate.opsForHash().hasKey(key, hashKey);
            } catch (Exception _ee) {
                _ee.printStackTrace();
                return false;
            } finally {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
            }
        } finally {
            RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
        }
    }

    public Object hGetValue(String key, String hashKey) {
        if (key == null || hashKey == null)
            return null;
        try {
            return stringRedisTemplate.opsForHash().get(key, hashKey);
        } catch (Exception _e) {
            _e.printStackTrace();
            try {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
                Thread.sleep(1);
                return stringRedisTemplate.opsForHash().get(key, hashKey);
            } catch (Exception _ee) {
                _ee.printStackTrace();
                return null;
            } finally {
                RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
            }
        } finally {
            RedisConnectionUtils.unbindConnection(stringRedisTemplate.getConnectionFactory());
        }
    }
}